/**
* @Description: 
* @Param: 
* @return: 
* @Author: Zwill
* @Date: 2020/2/25
*/
package command

import java.sql.{Connection, DriverManager}

object DBUtils {
  val username = "root"
  val password = "123456"
  val url = "jdbc:mysql://localhost:3306/testserver?useUnicode=true&characterEncoding=utf-8"

  classOf[com.mysql.jdbc.Driver]

  def getConnection(): Connection = {
    DriverManager.getConnection(url, username, password)
  }

  def close(conn: Connection): Unit = {
    try {
      if (!conn.isClosed() || conn != null) {
        conn.close()
      }
    }
    catch {
      case ex: Exception => {
        ex.printStackTrace()
      }
    }
  }
}
